package com.deep.sentinel.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * https://blog.csdn.net/weixin_38019299/article/details/120883690
 */
@RestController
@Slf4j
public class TestController {

    @GetMapping("/anno")
    @ResponseBody
    @SentinelResource(value = "alibaba-sentinel-flow-rules", blockHandler = "handleException")
    public String getOrder1() {
        return "访问正常";
    }

    @ResponseBody
    public String handleException(BlockException exception) {
        return "熔断、限流成功" + exception.getClass().getCanonicalName();
    }


}
